package work20241202_chap5oop;

/**
 * @author zdl
 * @date 2024/12/2
 */
public class Demo13 {
    public static void main(String[] args) {
        //多态向上转型
        Animal animal = new Pig();
        animal.eat();
        //向下转型
        Pig pig = (Pig)animal;
        pig.eat();
        pig.sleep();
    }
}
class Animal{
    public void eat(){
        System.out.println("吃饭");
    }
}
class Pig extends Animal{
    @Override
    public void eat() {
        System.out.println("猪吃杂食");
    }
    public void sleep(){
        System.out.println("睡觉！！！！");
    }
}
